import { useState, useEffect } from "react";
import { timeincrement } from "../store/actions/time";
import store from "../store";

export default function Time() {
    const [time, setTime] = useState(store.getState()["time"]["time"]);
    useEffect(() => {
        const timer = setInterval(() => {
            store.dispatch(timeincrement());
            setTime(store.getState()["time"]["time"]);
        }, 1000);
        () => clearInterval(timer);
    }, []);
    return (
        <>
            <div className='alert alert-warning'>当前时间为：{time}</div>
        </>
    );
}
